home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / OceanDVD (PL) small pic.ifs < prev    next >
Text File  |  2005-03-13  |  17KB  |  500 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=c) 2003 Grzegorz Jankowski
  8. Title=OceanDVD (PL)
  9. Description=Movie importation script for OceanDVD import info & small picture
  10. Site=http://www.oceandvd.pl
  11. Language=PL
  12. Version=1.0
  13. Requires=3.5.0
  14. Comments=Movie information & small picture importation|c) 2003 Grzegorz Jankowski (child@wp.pl)|based on script 'Filmweb (PL) small pic.ifs' by Piotr Kardasz & Adma's|14.02.2005 Improvements made by Adma's
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program FilmWeb;
  23. var
  24.   MovieName: string;
  25.  
  26. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  27. var
  28.   i: Integer;
  29. begin
  30.   result := -1;
  31.   if StartAt < 0 then
  32.     StartAt := 0;
  33.   for i := StartAt to List.Count-1 do
  34.     if Pos(Pattern, List.GetString(i)) <> 0 then
  35.     begin
  36.       result := i;
  37.       Break;
  38.     end;
  39. end;
  40.  
  41. procedure DelSpace(var Value: String);
  42. var
  43.   FullValue: String;
  44.   Counter: Integer;
  45. begin
  46.   if Value <> '' then
  47.   begin
  48.     FullValue := FullValue + StrGet(Value, 1);
  49.     for Counter := 2 to Length(Value) do
  50.     begin
  51.       if StrGet(Value, Counter) <> ' ' then
  52.         FullValue := FullValue + StrGet(Value, Counter)
  53.       else
  54.         if StrGet(FullValue, Length(FullValue)) <> ' ' then
  55.           FullValue := FullValue + ' ';
  56.     end;
  57.     Value := FullValue;
  58.   end
  59. end;
  60.  
  61. procedure DecodeHTML(var Value: String);
  62. var
  63.   FullValue, CharCode: String;
  64.   Counter: Integer;
  65. begin
  66.   if Value <> '' then
  67.   begin
  68.     FullValue := '';
  69.     Counter := 1;
  70.     repeat
  71.       if StrGet(Value, Counter) <> '&' then
  72.         begin
  73.           CharCode := copy(Value, Counter, 1);
  74.           case CharCode of
  75.             '▒': CharCode := '╣';
  76.             '╢': CharCode := '£';
  77.             'í': CharCode := 'Ñ';
  78.             '╝': CharCode := 'ƒ';
  79.             'ª': CharCode := 'î';
  80.             '¼': CharCode := 'Å';
  81.           end;
  82.           FullValue := FullValue + CharCode;
  83.           Counter := Counter + 1;
  84.         end
  85.       else
  86.         begin
  87.           CharCode := copy(Value, Counter, 7);
  88.           case CharCode of
  89.             'ą': FullValue := FullValue + '╣';
  90.             'ć': FullValue := FullValue + 'µ';
  91.             'ę': FullValue := FullValue + 'Ω';
  92.             'ł': FullValue := FullValue + '│';
  93.             'ń': FullValue := FullValue + '±';
  94.             'ó': FullValue := FullValue + '≤';
  95.             'ś': FullValue := FullValue + '£';
  96.             'ź': FullValue := FullValue + 'ƒ';
  97.             'ż': FullValue := FullValue + '┐';
  98.             'Ą': FullValue := FullValue + 'Ñ';
  99.             'Ć': FullValue := FullValue + '╞';
  100.             'Ę': FullValue := FullValue + '╩';
  101.             'Ł': FullValue := FullValue + 'ú';
  102.             'Ń': FullValue := FullValue + '╤';
  103.             'Ó': FullValue := FullValue + '╙';
  104.             'Ś': FullValue := FullValue + 'î';
  105.             'Ź': FullValue := FullValue + 'Å';
  106.             'Ż': FullValue := FullValue + '»';
  107.             'Š': FullValue := FullValue + ' ';
  108.             'š': FullValue := FullValue + 'í';
  109.             'Ţ': FullValue := FullValue + 'í';
  110.             'ţ': FullValue := FullValue + 'ú';
  111.             'Ť': FullValue := FullValue + 'ñ';
  112.             'ť': FullValue := FullValue + 'Ñ';
  113.             'Ŧ': FullValue := FullValue + 'î';
  114.             'ŧ': FullValue := FullValue + 'º';
  115.             'Ũ': FullValue := FullValue + '¿';
  116.             'ũ': FullValue := FullValue + '⌐';
  117.             'Ű': FullValue := FullValue + '¬';
  118.             'ű': FullValue := FullValue + '½';
  119.             'Ų': FullValue := FullValue + '¼';
  120.             'ų': FullValue := FullValue + '¡';
  121.             'Ŵ': FullValue := FullValue + '«';
  122.             'ŵ': FullValue := FullValue + '»';
  123.             'Ŷ': FullValue := FullValue + '░';
  124.             'ŷ': FullValue := FullValue + '▒';
  125.             'Ÿ': FullValue := FullValue + '▓';
  126.             'ƀ': FullValue := FullValue + '┤';
  127.             'Ɓ': FullValue := FullValue + '╡';
  128.             'Ƃ': FullValue := FullValue + '╢';
  129.             'ƃ': FullValue := FullValue + '╖';
  130.             'Ƅ': FullValue := FullValue + '╕';
  131.             'ƅ': FullValue := FullValue + '╣';
  132.             'Ɔ': FullValue := FullValue + '║';
  133.             'Ƈ': FullValue := FullValue + '╗';
  134.             'ƈ': FullValue := FullValue + '╝';
  135.             'Ɖ': FullValue := FullValue + '╜';
  136.             'Ɛ': FullValue := FullValue + '╛';
  137.             'Ƒ': FullValue := FullValue + '┐';
  138.             'ƒ': FullValue := FullValue + '└';
  139.             'Ɠ': FullValue := FullValue + '┴';
  140.             'Ɣ': FullValue := FullValue + '┬';
  141.             'ƕ': FullValue := FullValue + '├';
  142.             'Ɩ': FullValue := FullValue + '─';
  143.             'Ɨ': FullValue := FullValue + '┼';
  144.             'Ƙ': FullValue := FullValue + '╞';
  145.             'ƙ': FullValue := FullValue + '╟';
  146.             'Ȁ': FullValue := FullValue + '╚';
  147.             'ȁ': FullValue := FullValue + '╔';
  148.             'Ȃ': FullValue := FullValue + '╩';
  149.             'ȃ': FullValue := FullValue + '╦';
  150.             'Ȅ': FullValue := FullValue + '╠';
  151.             'ȅ': FullValue := FullValue + '═';
  152.             'Ȇ': FullValue := FullValue + '╬';
  153.             'ȇ': FullValue := FullValue + '╧';
  154.             'Ȉ': FullValue := FullValue + '╨';
  155.             'ȉ': FullValue := FullValue + '╤';
  156.             'Ȑ': FullValue := FullValue + '╥';
  157.             'ȑ': FullValue := FullValue + '╙';
  158.             'Ȓ': FullValue := FullValue + '╘';
  159.             'ȓ': FullValue := FullValue + '╒';
  160.             'Ȕ': FullValue := FullValue + '╓';
  161.             'ȕ': FullValue := FullValue + '╫';
  162.             'Ȗ': FullValue := FullValue + '╪';
  163.             'ȗ': FullValue := FullValue + '┘';
  164.             'Ș': FullValue := FullValue + '┌';
  165.             'ș': FullValue := FullValue + '█';
  166.             'Ƞ': FullValue := FullValue + '▄';
  167.             'ȡ': FullValue := FullValue + '▌';
  168.             'Ȣ': FullValue := FullValue + '▐';
  169.             'ȣ': FullValue := FullValue + '▀';
  170.             'Ȥ': FullValue := FullValue + 'α';
  171.             'ȥ': FullValue := FullValue + 'ß';
  172.             'Ȧ': FullValue := FullValue + 'Γ';
  173.             'ȧ': FullValue := FullValue + 'π';
  174.             'Ȩ': FullValue := FullValue + 'Σ';
  175.             'ȩ': FullValue := FullValue + 'σ';
  176.             'Ȱ': FullValue := FullValue + 'µ';
  177.             'ȱ': FullValue := FullValue + 'τ';
  178.             'Ȳ': FullValue := FullValue + 'Φ';
  179.             'ȳ': FullValue := FullValue + 'Θ';
  180.             'ȴ': FullValue := FullValue + 'Ω';
  181.             'ȵ': FullValue := FullValue + 'δ';
  182.             'ȶ': FullValue := FullValue + '∞';
  183.             'ȷ': FullValue := FullValue + 'φ';
  184.             'ȸ': FullValue := FullValue + 'ε';
  185.             'ȹ': FullValue := FullValue + '∩';
  186.             'ɀ': FullValue := FullValue + '≡';
  187.             'Ɂ': FullValue := FullValue + '±';
  188.             'ɂ': FullValue := FullValue + '≥';
  189.             'Ƀ': FullValue := FullValue + '≤';
  190.             'Ʉ': FullValue := FullValue + '⌠';
  191.             'Ʌ': FullValue := FullValue + '⌡';
  192.             'Ɇ': FullValue := FullValue + '÷';
  193.             'ɇ': FullValue := FullValue + '≈';
  194.             'Ɉ': FullValue := FullValue + '°';
  195.             'ɉ': FullValue := FullValue + '∙';
  196.             'ɐ': FullValue := FullValue + '·';
  197.             'ɑ': FullValue := FullValue + '√';
  198.             'ɒ': FullValue := FullValue + 'ⁿ';
  199.             'ɓ': FullValue := FullValue + '²';
  200.             'ɔ': FullValue := FullValue + '■';
  201.             'ɕ': FullValue := FullValue + ' ';
  202.             '&#x%DF;': FullValue := FullValue + '▀';
  203.             '4': FullValue := FullValue + '"';
  204.             '”': FullValue := FullValue + '"';
  205.             '„': FullValue := FullValue + '"';
  206.             '–': FullValue := FullValue + '-';
  207.           else
  208.             FullValue := FullValue + CharCode;  
  209.           end;
  210.           Counter := Counter + 7;
  211.         end;
  212.     until Counter > Length(Value);
  213.     HTMLDecode(FullValue);
  214.     Value := FullValue;
  215.   end
  216. end;
  217.  
  218. procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
  219. var
  220.   Line: string;
  221.   MovieTitle, MovieAddress: string;
  222.   StartPos, EndPos: Integer;
  223. begin
  224.   LineNr := FindLine('<li>', Page, LineNr);
  225.   if LineNr > -1 then
  226.   begin
  227.     PickTreeAdd('Znaleziono filmy:', '');
  228.     Line := Page.GetString(LineNr);
  229.     repeat
  230.       repeat
  231.         StartPos := pos('<li>', Line) + 4;
  232.         Line := copy(Line, StartPos, Length(Line) - StartPos + 1);
  233.         StartPos := pos('href="', Line) + 6;
  234.         Line := copy(Line, StartPos, Length(Line) - StartPos + 1);
  235.         MovieAddress := copy(Line, 1, pos('">', Line) - 1);
  236.         MovieAddress := 'http://www.oceandvd.pl/' + MovieAddress;
  237.         //MovieAddress := 'c:/film.htm';
  238.         StartPos := pos('">', Line) + 2;
  239.         Line := copy(Line, StartPos, Length(Line) - StartPos + 1);
  240.         MovieTitle := copy(Line, 1, pos('</a>', Line) - 1);
  241.         DecodeHTML(MovieTitle);
  242.         HTMLRemoveTags(MovieTitle);
  243.         PickTreeAdd(MovieTitle, MovieAddress);
  244.       until pos('<li>', Line) = 0;
  245.       LineNr := LineNr + 1;
  246.       Line := Page.GetString(LineNr);
  247.     until pos('<li>', Line) = 0;
  248.   end
  249.   else
  250.     break;
  251. end;
  252.  
  253. procedure AnalyzePage(Address: string);
  254. var
  255.   Page: TStringList;
  256.   LineNr: Integer;
  257. begin
  258.   Page := TStringList.Create;
  259.   Page.Text := GetPage(Address);
  260.   //Page.LoadFromFile(Address);
  261.   if pos('Wynik wyszukiwania', Page.Text) = 0 then
  262.     AnalyzeMoviePage(Page)
  263.   else
  264.   begin
  265.     PickTreeClear;
  266.     LineNr := 0;
  267.     AddMoviesTitles(Page, LineNr);
  268.     if PickTreeExec(Address) then
  269.       AnalyzePage(Address);
  270.   end;
  271.   Page.Free;
  272. end;
  273.  
  274. procedure AnalyzeMoviePage(Page: TStringList);
  275. var
  276.   Line, Value, FullValue: string;
  277.   LineNr, Counter: Integer;
  278.   StartPos, EndPos: Integer;
  279. begin
  280.  
  281.   // Tytu│ polski
  282.   LineNr := FindLine('class="tytuly"><b>', Page, 0);
  283.   if LineNr > -1 then
  284.   begin
  285.     Line := Page.GetString(LineNr);
  286.     StartPos := pos('class="tytuly"><b>', Line) + 18;
  287.     Line := copy(Line, StartPos, Length(Line) - StartPos);
  288.     EndPos := pos('(', Line);
  289.     if EndPos > 0
  290.     then EndPos := EndPos - 2
  291.     else EndPos := pos('<', Line) - 1;
  292.     Line := copy(Line, 1, EndPos);
  293.     DecodeHTML(Line);
  294.     SetField(fieldTranslatedTitle, Line);
  295.   end
  296.  
  297.   // Tytu│ oryginalny
  298.   LineNr := FindLine('class="tytuly"><b>', Page, 0);
  299.   if LineNr > -1 then
  300.   begin
  301.     Line := Page.GetString(LineNr);
  302.     StartPos := pos('class="tytuly"><b>', Line) + 18;
  303.     Line := copy(Line, StartPos, Length(Line) - StartPos);
  304.     StartPos := pos('(', Line);
  305.     if StartPos > 0 then
  306.     begin
  307.        StartPos := StartPos + 1;
  308.        EndPos := pos(')', Line);
  309.     end
  310.     else
  311.     begin
  312.       StartPos := 1;
  313.       EndPos := pos('<', Line);
  314.     end
  315.     Line := copy(Line, StartPos, EndPos-StartPos);
  316.     DecodeHTML(Line);
  317.     SetField(fieldOriginalTitle, Line);
  318.     end
  319.  
  320.   // îrednia ocena  
  321.   LineNr := FindLine('rednia ocena:', Page, 0);
  322.   if LineNr > -1 then
  323.   begin
  324.     Line := Page.GetString(LineNr);
  325.     StartPos := pos('rednia ocena:', Line) + 10;
  326.     Line := copy(Line, StartPos, Length(Line) - StartPos);
  327.     StartPos := pos('">', Line) + 2;
  328.     Line := copy(Line, StartPos, Length(Line) - StartPos);  
  329.     Value := IntToStr(Round(StrToInt(StrGet(Line, 1), 0) + (StrToInt(StrGet(Line, 3), 0) / 10) + (StrToInt(StrGet(Line, 4), 0) / 100)));
  330.     SetField(fieldRating, Value);
  331.   end
  332.  
  333.   // Kategoria
  334.   LineNr := FindLine('kat_', Page, 0);
  335.   if LineNr > -1 then
  336.   begin
  337.     Line := Page.GetString(LineNr);
  338.     StartPos := pos('kat_', Line) + 4;
  339.     Line := copy(Line, StartPos, Length(Line) - StartPos);
  340.     Line := copy(Line, 1, pos('.jpg', Line) - 1);
  341.     case Line of
  342.        '9': Value := 'Animowany';
  343.        '2': Value := 'Dramat';
  344.        '6': Value := 'Erotyczny';
  345.        '10': Value := 'Film Polski';
  346.        '1': Value := 'Horror';
  347.        '3': Value := 'Komedia';
  348.        '11': Value := 'Przygodowy';
  349.        '8': Value := 'Science Fiction';
  350.        '4': Value := 'Sensacyjny';
  351.        '5': Value := 'Thriller';
  352.     else
  353.       Value := '';
  354.     end;
  355.     SetField(fieldCategory, Value);
  356.   end
  357.     
  358.   // Kraj
  359.   LineNr := FindLine('produkcja:', Page, 0);
  360.   if LineNr > -1 then
  361.   begin
  362.     Line := Page.GetString(LineNr+1);
  363.     HTMLRemoveTags(Line);
  364.     DecodeHTML(Line);
  365.     DelSpace(Line);
  366.     Line := copy(Line, 2, Length(Line) - 1);
  367.     SetField(fieldCountry, Line);
  368.   end    
  369.   
  370.   // Rok produkcji
  371.   LineNr := FindLine('produkcja:', Page, 0);
  372.   if LineNr > -1 then
  373.   begin
  374.     Line := Page.GetString(LineNr+2);
  375.     HTMLRemoveTags(Line);
  376.     DecodeHTML(Line);
  377.     SetField(fieldYear, Line);
  378.   end
  379.  
  380.   // Re┐yseria
  381.   LineNr := FindLine('yseria:</b></td>', Page, 0);
  382.   if LineNr > -1 then
  383.   begin
  384.     Line := Page.GetString(LineNr+1);
  385.     HTMLRemoveTags(Line);
  386.     DecodeHTML(Line);
  387.     DelSpace(Line);
  388.     Line := copy(Line, 2, Length(Line) - 1);
  389.     SetField(fieldDirector, Line);
  390.   end
  391.  
  392.   // Producent (dystrybutor)
  393.   LineNr := FindLine('Dystrybucja:', Page, 0);
  394.   if LineNr > -1 then
  395.   begin
  396.     Line := Page.GetString(LineNr);
  397.     StartPos := pos('Dystrybucja:', Line) + 13;
  398.     Line := copy(Line, StartPos, Length(Line) - StartPos + 1);
  399.     DecodeHTML(Line);
  400.     SetField(fieldProducer, Line);
  401.   end  
  402.  
  403.   // Czas trwania
  404.   LineNr := FindLine('czas trwania:', Page, 0);
  405.   if LineNr > -1 then
  406.   begin
  407.     Line := Page.GetString(LineNr+1);
  408.     StartPos := pos('>', Line) + 1;
  409.     Line := copy(Line, StartPos, Length(Line) - StartPos);  
  410.     Value := copy(Line, 1, pos(' min', Line) - 1);
  411.     SetField(fieldLength, Value);
  412.   end
  413.   
  414.   // Opis filmu
  415.   LineNr := FindLine('<!-- OPIS FILMU -->', Page, 0);
  416.   if LineNr > -1 then
  417.   begin
  418.     Line := Page.GetString(LineNr+1);
  419.     DecodeHTML(Line);
  420.     HTMLRemoveTags(Line);
  421.     DelSpace(Line);
  422.     SetField(fieldDescription, Line);
  423.   end     
  424.   
  425.   // Obsada
  426.   LineNr := FindLine('wystΩpuj', Page, 0);
  427.   if LineNr > -1 then
  428.   begin
  429.     Line := Page.GetString(LineNr);
  430.     Value := '';
  431.     repeat
  432.       LineNr := LineNr + 1;
  433.       Line := Page.GetString(LineNr);
  434.       HTMLRemoveTags(Line);
  435.       Value := Value + Line;
  436.     until pos('<td>', Line) = 0;
  437.     DelSpace(Value);
  438.     Value := copy(Value, 2, Length(Line) - 1);
  439.     DecodeHTML(Value); 
  440.     SetField(fieldActors, Value);
  441.   end
  442.   
  443.   // Komentarz (Dane techniczne)
  444.   Line := '';
  445.   LineNr := FindLine('Dodatki', Page, 0);
  446.   if LineNr > -1 then
  447.   begin
  448.     Line := Page.GetString(LineNr);
  449.     Line := Line+''#13#10'';
  450.   end
  451.   LineNr := FindLine('<!-- OPIS TECHNICZNY FILMU -->', Page, 0);
  452.   if LineNr > -1 then
  453.   begin
  454.     Line := Line + Page.GetString(LineNr+2)+''#13#10''+Page.GetString(LineNr+3);
  455.   end
  456.     DecodeHTML(Line);
  457.     HTMLRemoveTags(Line);
  458.     DelSpace(Line);
  459.     SetField(fieldComments, Line);
  460.  
  461.   //URL
  462.   begin
  463.     setField(fieldURL,'http://www.oceandvd.pl/search.php?searchtype=1&cmd=find&phrase='+UrlEncode(MovieName));
  464.   end
  465.   
  466.  //Foto
  467.   LineNr:= FindLine('alt="ok│adka"', Page, 0);
  468.   if LineNr > -1
  469.  then begin
  470.     Line:= Page.GetString(LineNr);
  471.     StartPos:= Pos('img src=', Line) + 8;
  472.     Line:= Copy(Line, StartPos, Length(Line));
  473.     Value:= Copy(Line, 2, Pos('alt="ok│adka"', Line) - 4);
  474.     Value:= 'http://www.oceandvd.pl/' + Value;
  475.     HTMLRemoveTags(Value);
  476.     DecodeHTML(Value);
  477.     DelSpace(Value);
  478.     GetPicture(Value); // False = nie przechowuj zdjΩcia na zewnΩtrz ; przechowuj w pliku katalogu
  479.   end
  480.  
  481.   //DisplayResults;
  482. end;
  483.  
  484. begin
  485.   if CheckVersion(3,5,0) then
  486.   begin
  487.     MovieName := GetField(fieldOriginalTitle);
  488.     if MovieName = '' then
  489.       MovieName := GetField(fieldTranslatedTitle);
  490.     if Input('OceanDVD Import', 'Podaj tytu│ filmu:', MovieName) then
  491.     begin
  492.       AnalyzePage('http://www.oceandvd.pl/search.php?searchtype=1&cmd=find&phrase='+UrlEncode(MovieName));
  493.       //AnalyzePage('c:/lista.htm');
  494.     end;
  495.   end else
  496.     ShowMessage('Skrypt wymaga programu Ant Movie Catalog w wersji 3.5.0 lub nowszej');
  497. end.
  498.  
  499.  
  500.